//
//  XCBasicTableViewController.swift
//  XCMicroBo
//
//  Created by 1 on 16/3/7.
//  Copyright © 2016年 1. All rights reserved.
//

import UIKit

class XCBasicTableViewController: UITableViewController ,XCVisitorViewDelegate {
   
    private let flag = UserCount.shareAcount.userLoginFlage
    
    var myView : XCVisitorView?
    
    override func viewDidLoad() {
        
        
        
        if flag {
            
            super.viewDidLoad()
            
        }else{
            
            myView = XCVisitorView()
            view = myView
            
            addLeftAndRightBtn()

            
            //设置代理
            myView?.delegate = self
        }
        
        
        //设置全局颜色
        
        
    }
    
    //设置tabBarController左边和右边的按钮 并添加点击事件
    func addLeftAndRightBtn(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegist")
    }

    
    //实现代理方法
    func userWillLogin() {
        
        print("用户即将登录\(__FUNCTION__)")
        
        presentViewController(XCLoginNavigationController(), animated: true, completion: nil)
        
    }
    
    func userWillRegist() {
        
        print("用户即将注册\(__FUNCTION__)")
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
